package name.luojun.DBhelper.model;
public class SimpleColumn {
	private String name;
	private String type;
	private int length;
	private String comment;
	private String defaultvalue;
	private boolean notnull = false;
	public SimpleColumn(String columnName, String columnType, int datasize, boolean b, String defaultV, String comment) {
		this.name = columnName;
		this.type = columnType;
		this.length = datasize;
		this.notnull = b;
		this.defaultvalue = defaultV;
		this.comment = comment;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public int getLength() {
		return length;
	}
	public void setLength(int length) {
		this.length = length;
	}
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	public String getDefaultvalue() {
		return defaultvalue;
	}
	public void setDefaultvalue(String defaultvalue) {
		this.defaultvalue = defaultvalue;
	}
	public boolean getNotnull() {
		return notnull;
	}
	public void setNotnull(boolean notnull) {
		this.notnull = notnull;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((comment == null) ? 0 : comment.hashCode());
		result = prime * result + ((defaultvalue == null) ? 0 : defaultvalue.hashCode());
		result = prime * result + length;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + (notnull ? 1231 : 1237);
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}
	private boolean isStrEmpty(String str) {
		if (str == null) {
			return true;
		}
		if (str.trim().length() == 0) {
			return true;
		}
		return false;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SimpleColumn other = (SimpleColumn) obj;
		if (isStrEmpty(defaultvalue)) {
			if (!isStrEmpty(other.defaultvalue))
				return false;
		} else if (!defaultvalue.equals(other.defaultvalue))
			return false;
		if (other.length != 0)
			if (length != 0)
				if (other.length != length)
					return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equalsIgnoreCase(other.name))
			return false;
		if (notnull != other.notnull)
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equalsIgnoreCase(other.type))
			return false;
		return true;
	}
}
